<extend name="Public/base" />
<block name="style">
<style>
	.page-content{padding:15px 10px;}
	.search_pannl_div .single-col label{width:75px;} 
</style>
</block>
<block name="body">
  <include file="Public:artdialog" />

<div class="row">
   <div class="col-md-12">
       <div class="block-web">
   <!-- 商品列表 -->
   <form action="{:U('index')}" method="post"  id="SearchFrom">
           <div class="bgmain">
             <div class="header">
                  <div class="actions_diy">
                           <a href="{:U('add')}"   class="btn btn-default btn-primary">
                               <i class="fa fa-plus"></i>添加供应商
                           </a>
                       </div>
                     <h3 class="content-header">供应商列表</h3>
                 </div> 
                   <div class="block-web" style="margin: 0;padding:10px 20px 0px 0px;">
                       <div class="porlets-content">
                           <div class="row" style="margin-left:-45px;">
                               <div class="col-md-12">
                                   <div class="search_pannl_div">
                                       <table class="search_table">
                                           <tbody>
                                               <tr>
                                             <td class="single-col"> 
                                                       <label>关键词：</label><input style="width:120px;" type="text" id="keyword" name="keyword" placeholder="输入关键字" value="">
                                                       <button type="button" class="btn btn-success" formtarget="SearchFrom" id="searchBtn" ><i class="fa fa-search"></i> 搜索</button>  
                                                   </td>
                                               </tr>
                                           </tbody>
                                       </table>
                                   </div>
                               </div>
                           </div>
                       </div>
                   </div>
        </div>

   <div id="load_tb_div" style="padding:10px 0px 30px ;">
     <div class="table-responsive">
            <table id="sample-table-1"
              class="table table-striped table-bordered table-hover">
              <thead>
                <tr>
                  <th class="center"><label>
                  <input type="checkbox" class="ace" id="allsel" > <span class="lbl"></span>
                  </label></th>  
                  <th>公司名称</th>
                  <th>ABN</th> 
                  <th>联系人</th> 
                  <th>联系方式</th>   
                  <th>地址</th> 
                  <th>微信信息(头像/微信昵称/性别/地址)</th> 
                  <th>注册用户帐号</th> 
                   <th>状态</th>
                  <th>操作员</th>
                  <th>添加时间</th>
                  <th>操作</th>
                </tr> 
              </thead> 
              <tbody> 
                <volist name="list" id="o">
                <tr>
                  <td class="center"><label> <input
                      type="checkbox" class="ace"  value="{$o.sp_id}" > <span class="lbl"></span>
                  </label></td>  
                  <th>{$o.companyname}</th>
                  <th>{$o.abncode}</th> 
                  <th>{$o.linkname}</th>
                  <th>{$o.moblie}</th>
                  <th>{$o.address}</th> 
                  <th>
                  <if condition="$o['nickname'] neq '' or $o['sex'] neq '' or $o['country'] neq '' or $o['province'] neq ''">
                  <img src="{$o.headimgurl}" width="90px" width="90px">/{$o.nickname}/{$o['sex']==1?'男':'女'}/{$o.country},{$o.province},{$o.city}
                  </if>
                  </th>
               
                  <th>{$o.username}</th>
                  <th>{$active[$o['isactive']]}</th> 
                  <th>{$o.adminname}</th>
                  <th>{$o.createtime}</th> 
                  <td><a  class="J_ajax_del btn btn-white btn-sm"
                    href="{:U('delsupplier',array('id'=>$o['sp_id']))}">删除</a> <a
                     href="{:U('add',array('spid'=>$o['sp_id']))}"
                    class="btn btn-white btn-sm">修改</a>  
                    <a  class="btn btn-white btn-sm show_box"  href="javascript:;"  field="{:U('setsupplier',array('id'=>$o['sp_id']))}" >设置</a>
                  </td> 
                </tr>
                </volist>
              </tbody>
            </table>
            <div class="pagination" style="margin:0px;">
               <a class="btn pull-left btn-danger" id="pdid">批量删除</a> {$page}
            </div>
          </div> 
   </div>
           </form>
       </div><!--/porlets-content-->
   </div><!--/block-web-->
</div><!--/col-md-12-->
</block>
<block name="script">
<script type="text/javascript" src="__PUBLIC__/Admin/js/common_manage.js"></script>
<script type="text/javascript">
var pdelurl="{:U('delsupplier')}";
var backurl="{:U('index')}";
$(function(){ 
   $("#searchBtn").bind("click",function(){$("#SearchFrom").submit();})
   $("#pdid").bind("click",fndel);
   $("#allsel").bind("click",checkSel);
   $(".show_box").bind("click",setactive);
 }); 
 
 var setactive=function(){ 
	 //debugger;
	 var url=$(this).attr("field");
	 if(!url)return false;
	 title="修改供应商状态";
	 var _html="<select id='active_id'><option value='' selected>选择状态</option><option value='0'>无效</option><option value='1' >有效</option><option value='2'>资料不合格</option><option value='3'> 删除标识</option></select>";
	 art.dialog({title:title,content:_html, width:'200px', height:'100px', opacity: 0.2, id: "setstatusid",
	  	  ok: function () {  
	  		    fnSetActive(url); 
	  	        return false;
	  	    },
	  	    okVal:'确定',
	  	    cancelVal: '取消',
	  	    cancel: function(){this.close();}	
	  });   
 }

 var fnSetActive=function(_url){
	 //debugger
    debugger;
	var _opval= $("#active_id").val();
	if(_opval==""){
		alert("请选择状态");
		return false;
	}
	
	$.ajax({
        'url': _url,
        'data': {actives:_opval},
        'dataType': 'json',
        'type': 'get',
        success: function (data) {
       	 //debugger
       	 if(!data){
       		 art.dialog({title:'温馨提示',content: '提交数据保存失败', ok: function () {this.close();return false;},okval:'确定'});
       		 return;
       	 }
       	 
       	 art.dialog({title:'温馨提示',content: data.msg, ok: function () {this.close();return false;},okval:'确定'}); 
         if (data.staute =="success") {   
           	 location.replace(backurl);
         }

        }, error: function (err) { 
       	 //debugger
       	 art.dialog({title:'温馨提示',content: err.responseText, ok: function () {this.close();return false;},okval:'确定'});
        } 
    });  
	
 }
 
 </script>
</block>
